// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import routes from './router'
import VueRouter from 'vue-router'
import ElementUI from 'element-ui'
import NProgress from 'nprogress'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store'
import i18n from './i18n/i18n'

Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.use(NProgress)

Vue.config.productionTip = false

const router = new VueRouter({
  //取消#后缀
  mode: 'hash',
  routes
})

router.beforeEach((to, from, next) => {
  NProgress.start();
  if (to.path == '/') {
    next('/login');
  }else{
    next();
  }
})
router.afterEach(() => {
  NProgress.done();
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})
